unit ucAgreementWindowOtliv;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
  Dialogs, ComCtrls, ToolWin, Grids, DBGridEh, StdCtrls, ImageTools;

type
  TfcAgreementWindowOtliv = class(TFrame)
    GroupBox6: TGroupBox;
    DBGridEh6: TDBGridEh;
    tbAgreementWindowOtliv: TToolBar;
    tbAddAgreementWindowOtliv: TToolButton;
    tbDelAgreementWindowOtliv: TToolButton;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    procedure tbAddAgreementWindowOtlivClick(Sender: TObject);
    procedure tbDelAgreementWindowOtlivClick(Sender: TObject);
    procedure DBGridEh6DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumnEh; State: TGridDrawState);
    procedure DBGridEh6KeyPress(Sender: TObject; var Key: Char);
  private
  public
  end;

implementation

uses uDBData, uAddAgreementWindowOtliv;

{$R *.dfm}

procedure TfcAgreementWindowOtliv.tbAddAgreementWindowOtlivClick(
  Sender: TObject);
begin
  if(fDBData.dAgreementWindow.DataSet.Active)then
  begin
    if(fDBData.dAgreementWindow.DataSet.IsEmpty = False)then
    begin
      fDBData.InsertRecord(fDBData.dAgreementWindowOtliv);
      fAddAgreementWindowOtliv.ShowModal();
    end;
  end;
end;

procedure TfcAgreementWindowOtliv.tbDelAgreementWindowOtlivClick(
  Sender: TObject);
begin
  fDBData.DeleteRecord(fDBData.dAgreementWindowOtliv);        
end;

procedure TfcAgreementWindowOtliv.DBGridEh6DrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumnEh;
  State: TGridDrawState);
begin
  //try
    if(Column.Index = 0)then
    begin
      (Sender as TDBGridEh).Canvas.Draw(Rect.Left, Rect.Top, fDBData.GetOtlivImage());
    end;
  //except
  //end;
end;

procedure TfcAgreementWindowOtliv.DBGridEh6KeyPress(Sender: TObject;
  var Key: Char);
begin
  if Key = #13 then (Sender as TDBGridEh).DataSource.DataSet.Post;
end;

end.
